<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta name="author" content="wangzhichao">
	<title>个人卡申请/单位司机卡申请 管理</title>
	<script language="javascript" src="../script/common.js" type="text/javascript"></script>
	<script language="javascript" type="text/javascript">
		var org = Common.cOrg();		//当前单位
		var qt = {};				//数据表格对象
		var inited=false;
		var baseType="";			//基本卡类型
		var cardType="";			//卡片类型id
		var titlename="";			//列表名称
		//初始化数据
		function load(){
			searchForm.organization.value = org.id;
			searchForm.cardStatus.value = CardUserStatus.CUSTOMIZE;
			baseType = getPara("baseType");
			cardType = getPara("cardType");
			searchForm.cardType.value = cardType;
			if(baseType==BaseCardType.PERSONAL){
				searchForm.type.value = CardUserType.NAME;
				$("companyName").innerHTML = "";
			}else if(baseType==BaseCardType.COMPANY){
				searchForm.type.value = CardUserType.DRIVER;
				$("companyName").innerHTML = "<label>单位名称</label> <input type='text' name='companyName'><a class=orga title='选择单位' href='javascript:void(0)' onclick='selCompany()'>&nbsp;&nbsp;</a>"
			}
			titlename = getPara("titlename"); 
			createTable();
			qt.showTable();
		}
		//生成查询语句
		function createTable(){
			var discolumns;
		  	var columns = []
			columns[0] = {type:"checkbox"};
			columns[1] = {render:parentfun};
			if(baseType==BaseCardType.PERSONAL){
				discolumns = [0,1,2,3,6];
			}else if(baseType==BaseCardType.COMPANY){
				columns[4] = {render:companyfun};
				discolumns = [0,1,2,4,5,6];
			}
			qt = new QueryTable("card_request_newuser","searchForm","datalist",columns,{title:titlename+"客户列表",displayColumns:discolumns});
			
		}
		//客户姓名的超链接
		function parentfun(v,r){
			return "<a href=# onclick=showDetailparent("+r[0]+","+r[8]+")>"+v+"</a>"
		}
		//点击弹出客户明细信息
	    function showDetailparent(userId,cuId){
			var ckSize = 655;
			if(!cuId){
				ckSize = 415;
			}
			var v = openDialogFrame("/store/sel_customer_and_company_detail.html?userId="+userId+"&cuId="+cuId+"&cardUserType="+CardUserType.NAME,'司机明细信息',ckSize,750);
		}
		function companyfun(v,r){
			return "<a href=# onclick=showDetailUnit("+r[7]+","+r[9]+")>"+v+"</a>"
		}
		function showDetailUnit(userId,cuId){
			var v = openDialogFrame("/store/sel_customer_and_company_detail.html?userId="+userId+"&cuId="+cuId+"&cardUserType="+CardUserType.COMPANY,'单位明细信息',750,750);
		}
		//保存方法
		function onSave(){
			var ids = qt.getBoxValue();
			ids = ids.split(",");
			var idd=getPara("idd");
			if(ids==""){
				showInformation("请选择客户");
				return;
			}
			DWR.call("cardRequestService.addCustomer",idd,ids,function(){
				dialogBackValue(true)
			});
		}
		function selCompany(){
			var v = openDialogFrame("/store/sel_unit_manage.html",'选择单位',475,700);
			if(v){
			    searchForm.companyId.value=v[0];
				searchForm.companyName.value = v[2];
			}
		}
	</script>
</head>
<body class="body" onload='load()'>
	<div class="form">	
	<form id="searchForm" name="searchForm">
	<input type="hidden" name="type">
	<input type="hidden" name="organization">
	<input type="hidden" name="cardType">
	<input type="hidden" name="companyId">
	<input type="hidden" name="parentOrg">
	<input type="hidden" name="cardStatus">
	<table cellSpacing=0 cellPadding=6 width="100%" border=0>
			<tr>
			<td><label>客户名称</label> <input type="text" name="personName"></td>
			<td id="companyName"></td>
			<td><button type="button" onclick="qt.showTable()">查   询</button></td>
			</tr>
	</table>
	</form>
	</div>
	<!--查询结构列表-->
	<div id="datalist"></div>
</body>
</html>
